package io.renren.modules.app.controller.user;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.renren.modules.app.entity.user.UserEducationEntity;
import io.renren.modules.app.service.info.EduBgdService;
import io.renren.modules.app.service.user.UserEducationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

import javax.annotation.Resource;


/**
 *
 *
 * @author lym
 * @email 928185446qq.com
 * @date 2023-12-21 17:06:24
 */
@RestController
@RequestMapping("userEducation")
public class UserEducationController {
    @Autowired
    private UserEducationService UserEducationService;
    @Resource
    private EduBgdService eduBgdService;

    /**
     * 通过resumeId查询
     */
    @RequestMapping("/queryByResumeId/{resumeId}")
    public R queryByResumeId(@PathVariable("resumeId") Integer resumeId){
        UserEducationEntity userEducation = UserEducationService.queryByResumeId(resumeId);
        return R.ok().put("userEducation", userEducation);
    }
    @GetMapping("/getEduBgd")
    public R getEduBgd(){
        return R.ok().put("eduBgd",eduBgdService.list());
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = UserEducationService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		UserEducationEntity UserEducation = UserEducationService.getById(id);

        return R.ok().put("UserEducation", UserEducation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody UserEducationEntity userEducation){
        userEducation.setAddtime(new Date());
        userEducation.setDeletestatus(false);
		UserEducationService.saveOrUpdate(userEducation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEducationEntity UserEducation){
		UserEducationService.updateById(UserEducation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		UserEducationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
